
package adoc;

/**
 *
 * @author ILikePancakes
 */
import java.io.File;
import javax.swing.filechooser.*;

public class DocumentFileFilter extends FileFilter {

    //Accept all directories and all gif, jpg, tiff, or png files.
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }
        String[] extensions = new String[] {
            "DOCX", "ODT", "XLSX", "ODS", "PPTX",
            "PPSX", "ODP", "PDF", "TIF", "TIFF", "JFIF", "JPEG", "JPG", "PNG"
        };
        String extension = AdocUtilities.getExtension(f.getName());
        if (extension != null) {
            for (int i = 0; i < extensions.length; i++) if (extensions[i].equals(extension)) return true;
        }
        //if (AdocUtilities.isValidDocumentType(AdocUtilities.getRealMimeType(f))) return true; <------- LABAI suletins

        return false;
    }

    //The description of this filter
    public String getDescription() {
        return "Documents (.docx, .xlsx, ...)";
    }
}
